<?php
declare(strict_types=1);

namespace app\model\api\admin\general;

use think\Model;
use think\model\concern\SoftDelete;

class Dict extends Model
{
    use SoftDelete;

    // protected $jsonAssoc = true;
    protected $json = ['extend'];

    public const TYPE = [
        'KEY' => [1, '键型'],
        'VALUE' => [2, '值型']
    ];

    public static function onAfterWrite($model)
    {
        self::clearCache();
    }

    // 清理缓存
    private static function clearCache()
    {
        \think\facade\Cache::delete(\app\common\constant\CacheKey::DictList);
    }
}
